package com.eastfair.mobile.service.impl;

//import com.baomidou.dynamic.datasource.annotation.DS;
import com.eastfair.builder.ExhibitorFeign;
import com.eastfair.builder.dto.ExhibitorDTO;
import com.eastfair.builder.vo.ExhibitorVO;
import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.mobile.service.MobileDataService;
import com.eastfair.venuebooking.api.ServiceProviderCreditFeign;
import com.eastfair.venuebooking.api.ExhibitionManageFeign;
import com.eastfair.venuebooking.api.ServiceProviderSpaceFeign;
import com.eastfair.venueservice.dto.ExhibitionManageQuery;
import com.eastfair.venueservice.dto.ServiceProviderCreditDTO;
import com.eastfair.venueservice.dto.ServiceProviderSpaceDTO;
import com.eastfair.venueservice.dto.ServiceProviderSpaceQuery;
import com.eastfair.venueservice.vo.ExhibitionManageVO;
import com.eastfair.venueservice.vo.ServiceProviderCreditVO;
import com.eastfair.venueservice.vo.ServiceProviderSpaceVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author lyw
 * @Date 2022/9/13 14:09
 */
@Slf4j
@Service
//@DS("#thread.tenant")
public class MobileDataServiceImpl implements MobileDataService {
    @Autowired
    private ExhibitorFeign exhibitorFeign;
    @Autowired
    private ExhibitionManageFeign exhibitionManageFeign;
    @Autowired
    private ServiceProviderSpaceFeign serviceProviderSpaceFeign;
    @Autowired
    private ServiceProviderCreditFeign serviceProviderCreditFeign;



    /**
     * 获取展商列表
     * @param exhibitorDTO
     * @return
     */
    @Override
    public List<ExhibitorVO> queryExhibitors(ExhibitorDTO exhibitorDTO) {
        R<List<ExhibitorVO>> r = exhibitorFeign.queryExhibitors(exhibitorDTO);
        if(!r.getIsSuccess()){
            throw BizException.wrap(r.getCode(),r.getMsg());
        }
        return r.getData();
    }

    /**
     * 获取正在进行中的展会
     * @param exhibitionManageQuery
     * @return
     */
    @Override
    public ExhibitionManageVO queryExhibitionManageByProvider(ExhibitionManageQuery exhibitionManageQuery) {
        R<ExhibitionManageVO> r = exhibitionManageFeign.queryExhibitionManageByProvider(exhibitionManageQuery);
        if (!r.getIsSuccess()) {
            throw BizException.wrap(r.getCode(), r.getMsg());
        }
        return r.getData();
    }

    /**
     * 查询服务商使用展厅
     * @param serviceProviderSpaceQuery
     * @return
     */
    @Override
    public List<ServiceProviderSpaceVO> queryServiceProviderSpace(ServiceProviderSpaceQuery serviceProviderSpaceQuery) {
        R<List<ServiceProviderSpaceVO>> r = serviceProviderSpaceFeign.queryServiceProviderSpace(serviceProviderSpaceQuery);
        if (!r.getIsSuccess()) {
            throw BizException.wrap(r.getCode(), r.getMsg());
        }
        return r.getData();
    }

    /**
     *
     * @param serviceProviderId
     * @return
     */
    @Override
    public ServiceProviderCreditVO getServiceProviderCreditById(Long serviceProviderId) {
        R<ServiceProviderCreditVO> r = serviceProviderCreditFeign.getServiceProviderCreditById(serviceProviderId);
        if (!r.getIsSuccess()) {
            throw BizException.wrap(r.getCode(), r.getMsg());
        }
        return r.getData();
    }

    /**
     * 添加服务商星级分
     * @param serviceProviderCreditDTO
     * @return
     */
    @Override
    public Boolean saveServiceProviderCreditInfo(ServiceProviderCreditDTO serviceProviderCreditDTO) {
        R<Boolean> r = serviceProviderCreditFeign.saveServiceProviderCreditInfo(serviceProviderCreditDTO);
        if (!r.getIsSuccess()) {
            throw BizException.wrap(r.getCode(), r.getMsg());
        }
        return r.getData();
    }
}
